*****************************************************************************************
*** This do file replicates the findings for  											*/
*** The Political Economy of the UNSC													*/
*** James Raymond Vreeland (Georgetown University)										*/
*** Axel Dreher (Heidelberg University, Goettingen University, KOF, CESifo, IZA)		*/
*****************************************************************************************
*** Last update VREELAND VERSION: December 30, 2013.                                    * 
*****************************************************************************************
/* Note: This do file uses the dataset "UNSC database 00"                               */ 
/* created by the do-file UNSC Book 04, also sent on on May 26, 2013                    */ 
/* Change local DIR to the directory where you store the raw data						*/
*****************************************************************************************

capture log close
set more off
version 11.0
drop _all
clear matrix
clear mata
set mem 2000m
set mat 800

***********************************************************************************
local DIR = "C:\Users\ereynol4.UOFI\00Current\Collaborations\ForeignAidAndSecurityCouncil\DreherVreelandRepFiles\Chapter 5" 
cd "`DIR'" 
***********************************************************************************
log using "Vreeland_&_Dreher_2014_chapter5.log" , replace


** checks whether folder "output tables" (where tables are stored) exists and creates it if not
/*program define confirmdir, rclass
 	local cwd `"`c(pwd)'"'
	quietly capture cd `"`1'"'
	local confirmdir=_rc 
	quietly cd `"`cwd'"'
	return local confirmdir `"`confirmdir'"'
end 
	confirmdir `"output tables"'		/* does folder "output tables" exist? */
		if `r(confirmdir)'!=0  {  		/* folder does not yet exist */
			mkdir "output tables"  		/* makes the folder  */
					      } 
	      else {
			di "folder output tables already exists"
			}
	
program drop confirmdir */



use "Chapter 5.dta", clear

*******************************************************************************************************************************************
******************************************************** Regressions **********************************************************************
*******************************************************************************************************************************************

/*
List of tables produced below: 

Chapter 5
	Table 5.1: "Bilateral"
	Table 5.2: "Bilateral Africa"
	Table 5.3: "World Bank"
	Table 5.4: "United Nations"
	Table 5.5: "United Nations AFRICA"
	Table 5.6: "AfDB"
	Table 5.7: "Swing Voter"
	Appendix 5.a1: "Descriptive Statistics"
	Figure 5.1 Bilateral development aid to UNSC members and non-UNSC members

*/

****** Table 5.1 "Bilateral"

* Model 1
xtreg 	odadisUSA_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c1

* Model 2
xtreg 	odadisUSA_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe level(90)
estimates store c2

	***Increase efficiency by dropping insignificant ctrl vars:
xtreg 	odadisUSA_ln unsc0 unsc1 unsc2 pariah war milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe level(90)

* Model 3
xtreg 	odadisJPN_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c3

* Model 4
xtreg 	odadisJPN_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c4

* Model 5
xtreg 	odadisDEU_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe level(90)
estimates store c5

	***Increase efficiency by dropping insignificant ctrl vars:
		xtreg 	odadisDEU_ln unsc war polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
			if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe level(90)
* Model 6
xtreg 	odadisDEU_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c6

* Model 7
xtreg 	odadisGBR_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c7

* Model 8
xtreg 	odadisGBR_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c8

* Model 9
xtreg 	odadisFRA_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c9

* Model 10
xtreg 	odadisFRA_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c10

estout c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 ///
				using "output tables\table 51 bilateral - GINA.txt", replace label delimiter(_tab) noabbrev  						///
				cells(b(star fmt(%9.2f)) t(par abs fmt(2))) style(fixed) starlevels(* 0.10 ** 0.05 *** 0.01) 				///
				drop(_cons o.* ydumREP* cotrendregREP* egytrendREP)															///
				stats(N r2, labels("Number of observations" "R-squared") 													///
				fmt(0 2)) order(unsc unsc0 unsc1 unsc2 pariah 																///
				war rgdpl2_ln polity2new milit_aid_ln)																		///
				mlabels("(1)" "(2)" "(3)" "(4)" "(5)" "(6)" "(7)" "(8)" "(9)" "(10)")	


				
****** Table 5.2 "Bilateral Africa"

* Model 1
xtreg 	odadisUSA_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c1

* Model 2
xtreg 	odadisUSA_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe level (90)
estimates store c2

	***Increase efficiency by dropping insignificant ctrl vars:
	xtreg 	odadisUSA_ln unsc0 unsc1 unsc2 pariah war milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
			if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
* Model 3
xtreg 	odadisJPN_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c3

* Model 4
xtreg 	odadisJPN_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c4

* Model 5
xtreg 	odadisDEU_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c5

* Model 6
xtreg 	odadisDEU_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c6

* Model 7
xtreg 	odadisGBR_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c7

* Model 8
xtreg 	odadisGBR_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c8

* Model 9
xtreg 	odadisFRA_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c9

* Model 10
xtreg 	odadisFRA_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c10

estout c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 ///
				using "output tables\table 52 bilateral africa.txt", replace label delimiter(_tab) noabbrev  				///
				cells(b(star fmt(%9.2f)) t(par abs fmt(2))) style(fixed) starlevels(* 0.10 ** 0.05 *** 0.01) 				///
				drop(_cons o.* ydumREP* cotrendregREP* egytrendREP)															///
				stats(N r2, labels("Number of observations" "R-squared") 													///
				fmt(0 2)) order(unsc unsc0 unsc1 unsc2 pariah 																///
				war rgdpl2_ln polity2new milit_aid_ln)																		///
				mlabels("(1)" "(2)" "(3)" "(4)" "(5)" "(6)" "(7)" "(8)" "(9)" "(10)")	



****** Table 5.3 "World Bank"

* Model 1
xtreg 	aiddisIBRD_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe /* 1969-2007 */
estimates store c1

* Model 2
xtreg 	aiddisIBRD_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe /* 1969-2007 */
estimates store c2

* Model 3
xtreg 	aiddisIBRD_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe /* 1969-2007 */
estimates store c3

* Model 4
xtreg 	aiddisIBRD_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe /* 1969-2007 */
estimates store c4

* Model 5
xtreg 	aiddisIDA_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe /* 1969-2007 */
estimates store c5

* Model 6
xtreg 	aiddisIDA_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe /* 1969-2007 */
estimates store c6

* Model 7
xtreg 	aiddisIDA_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe /* 1969-2007 */
estimates store c7

* Model 8
xtreg 	aiddisIDA_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe /* 1969-2007 */
estimates store c8

estout c1 c2 c3 c4 c5 c6 c7 c8 ///
				using "output tables\table 53 World Bank.txt", replace label delimiter(_tab) noabbrev  						///
				cells(b(star fmt(%9.2f)) t(par abs fmt(2))) style(fixed) starlevels(* 0.10 ** 0.05 *** 0.01) 				///
				drop(_cons o.* ydumREP* cotrendregREP* egytrendREP)															///
				stats(N r2, labels("Number of observations" "R-squared") 													///
				fmt(0 2)) order(unsc unsc0 unsc1 unsc2 pariah 																///
				war rgdpl2_ln polity2new milit_aid_ln)																		///
				mlabels("(1)" "(2)" "(3)" "(4)" "(5)" "(6)" "(7)" "(8)")	



****** Table 5.4 "United Nations"

* Model 1
xtreg 	odadisUN_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe /* United Nations Regular Programme for Technical Assistance, established by General Assembly resolution 58(I) in 1946*/
estimates store c1

* Model 2
xtreg 	odadisUN_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe /* United Nations Regular Programme for Technical Assistance, established by General Assembly resolution 58(I) in 1946*/
estimates store c2

* Model 3
xtreg 	odadisWFP_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1960, cluster(code) fe /* The WFP was first established in 1961 */
estimates store c3

* Model 4
xtreg 	odadisWFP_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1960, cluster(code) fe /* The WFP was first established in 1961 */
estimates store c4

* Model 5
xtreg 	odadisUNDP_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1964, cluster(code) fe /* UNDP was founded on 22 November 1965 */
estimates store c5

* Model 6
xtreg 	odadisUNDP_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1964, cluster(code) fe /* UNDP was founded on 22 November 1965 */
estimates store c6

* Model 7
xtreg 	odadisUNICEF_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c7

* Model 8
xtreg 	odadisUNICEF_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c8

* Model 9
xtreg 	odadisUNHCR_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c9

* Model 10
xtreg 	odadisUNHCR_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c10

* Model 11
xtreg 	odadisUNTA_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe /* United Nations Regular Programme for Technical Assistance, established by General Assembly resolution 58(I) in 1946*/
estimates store c11

* Model 12
xtreg 	odadisUNTA_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe /* United Nations Regular Programme for Technical Assistance, established by General Assembly resolution 58(I) in 1946*/
estimates store c12

estout c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 ///
				using "output tables\table 54 United Nations.txt", replace label delimiter(_tab) noabbrev  					///
				cells(b(star fmt(%9.2f)) t(par abs fmt(2))) style(fixed) starlevels(* 0.10 ** 0.05 *** 0.01) 				///
				drop(_cons o.* ydumREP* cotrendregREP* egytrendREP)															///
				stats(N r2, labels("Number of observations" "R-squared") 													///
				fmt(0 2)) order(unsc unsc0 unsc1 unsc2 pariah 																///
				war rgdpl2_ln polity2new milit_aid_ln)																		///
				mlabels("(1)" "(2)" "(3)" "(4)" "(5)" "(6)" "(7)" "(8)" "(9)" "(10)" "(11)" "(12)")	


				
****** Table 5.5 "United Nations Africa"

* Model 1
xtreg 	odadisUN_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe /* United Nations Regular Programme for Technical Assistance, established by General Assembly resolution 58(I) in 1946*/
estimates store c1

* Model 2
xtreg 	odadisUN_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe /* United Nations Regular Programme for Technical Assistance, established by General Assembly resolution 58(I) in 1946*/
estimates store c2

* Model 3
xtreg 	odadisWFP_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1960, cluster(code) fe /* The WFP was first established in 1961 */
estimates store c3

* Model 4
xtreg 	odadisWFP_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1960, cluster(code) fe /* The WFP was first established in 1961 */
estimates store c4

* Model 5
xtreg 	odadisUNDP_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1964, cluster(code) fe /* UNDP was founded on 22 November 1965 */
estimates store c5

* Model 6
xtreg 	odadisUNDP_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1964, cluster(code) fe /* UNDP was founded on 22 November 1965 */
estimates store c6

* Model 7
xtreg 	odadisUNICEF_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c7

* Model 8
xtreg 	odadisUNICEF_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c8

* Model 9
xtreg 	odadisUNHCR_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c9

* Model 10
xtreg 	odadisUNHCR_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c10

* Model 11
xtreg 	odadisUNTA_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe /* United Nations Regular Programme for Technical Assistance, established by General Assembly resolution 58(I) in 1946*/
estimates store c11

* Model 12
xtreg 	odadisUNTA_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe /* United Nations Regular Programme for Technical Assistance, established by General Assembly resolution 58(I) in 1946*/
estimates store c12

estout c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 ///
				using "output tables\table 55 United Nations Africa.txt", replace label delimiter(_tab) noabbrev  					///
				cells(b(star fmt(%9.2f)) t(par abs fmt(2))) style(fixed) starlevels(* 0.10 ** 0.05 *** 0.01) 				///
				drop(_cons o.* ydumREP* cotrendregREP* egytrendREP)															///
				stats(N r2, labels("Number of observations" "R-squared") 													///
				fmt(0 2)) order(unsc unsc0 unsc1 unsc2 pariah 																///
				war rgdpl2_ln polity2new milit_aid_ln)																		///
				mlabels("(1)" "(2)" "(3)" "(4)" "(5)" "(6)" "(7)" "(8)" "(9)" "(10)" "(11)" "(12)")	

				
****** Table 5.6 "AfDF"

* Model 1
xtreg 	odadisAfDF_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959 & year>1973 & africa==1, cluster(code) fe /* African Development Fund started operations in 1974 */
estimates store c1

* Model 2
xtreg 	odadisAfDF_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959 & year>1973 & africa==1, cluster(code) fe /* African Development Fund started operations in 1974 */
estimates store c2

* Model 3
xtreg 	odadisAfDF_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if year<1982 & africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959 & year>1973 & africa==1, cluster(code) fe /* African Development Fund started operations in 1974 */
estimates store c3

* Model 4
xtreg 	odadisAfDF_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if year<1982 & africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959 & year>1973 & africa==1, cluster(code) fe /* African Development Fund started operations in 1974 */
estimates store c4

* Model 5
xtreg 	odadisAfDF_ln unsc pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if year>=1982 & africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959 & year>1973 & africa==1, cluster(code) fe /* African Development Fund started operations in 1974 */
estimates store c5

* Model 6
xtreg 	odadisAfDF_ln unsc0 unsc1 unsc2 pariah war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if year>=1982 & africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959 & year>1973 & africa==1, cluster(code) fe /* African Development Fund started operations in 1974 */
estimates store c6


estout c1 c2 c3 c4 c5 c6  ///
				using "output tables\table 56 AfDF.txt", replace label delimiter(_tab) noabbrev  							///
				cells(b(star fmt(%9.2f)) t(par abs fmt(2))) style(fixed) starlevels(* 0.10 ** 0.05 *** 0.01) 				///
				drop(_cons o.* ydumREP* cotrendregREP* egytrendREP)															///
				stats(N r2, labels("Number of observations" "R-squared") 													///
				fmt(0 2)) order(unsc unsc0 unsc1 unsc2 pariah 																///
				war rgdpl2_ln polity2new milit_aid_ln)																		///
				mlabels("(1)" "(2)" "(3)" "(4)" "(5)" "(6)")	

		
****** Table 5.7 "Swing Voter"

* Model 1
xtreg 	odadisUSA_ln unsc2 pariah pariah_sc2 usa_ally usa_ally_sc2 war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c1

*USA (pariah ally) just AFRICA --- no allies and only 1 observation where unsc2==1 & pariah==1: Nigeria 1994. Makes no sense run. 

* Model 2
xtreg 	odadisUSA_ln unsc2 low_affinity_usa low_usa_sc2 high_affinity_usa high_usa_sc2 war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c2

* Model 3
xtreg 	odadisUSA_ln unsc2 low_affinity_usa low_usa_sc2 high_affinity_usa high_usa_sc2 war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
estimates store c3


estout c1 c2 c3 ///
				using "output tables\table 57 swing.txt", replace label delimiter(_tab) noabbrev  							///
				cells(b(star fmt(%9.2f)) t(par abs fmt(2))) style(fixed) starlevels(* 0.10 ** 0.05 *** 0.01) 				///
				drop(_cons o.* ydumREP* cotrendregREP* egytrendREP)															///
				stats(N r2, labels("Number of observations" "R-squared") 													///
				fmt(0 2)) order(unsc2 pariah pariah_sc2 usa_ally usa_ally_sc2 												///
				low_affinity_usa low_usa_sc2 high_affinity_usa high_usa_sc2 												///
				war rgdpl2_ln polity2new milit_aid_ln)																		///
				mlabels("(1)" "(2)" "(3)" )	


*Producing the variance-covariance matrix to calculatethe marginal effects of interaction terms (also see t57 interactions.xls): 
	*USA (pariah ally) MODEL 1
	xtreg 	odadisUSA_ln unsc2 pariah pariah_sc2 usa_ally usa_ally_sc2 war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
	vce

	*USA (unga) MODEL 2
	xtreg 	odadisUSA_ln unsc2 low_affinity_usa low_usa_sc2 high_affinity_usa high_usa_sc2 war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
	vce

	*USA (unga) just AFRICA MODEL 3
	xtreg 	odadisUSA_ln unsc2 low_affinity_usa low_usa_sc2 high_affinity_usa high_usa_sc2 war rgdpl2_ln polity2new milit_aid_ln ydumREP* cotrendregREP* egytrendREP 	///
		if africa==1 & hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) fe
	vce

	
****** Table 5.a1 Descriptive Data

use "Chapter 5.dta", clear

reg 	odadisUSA_ln unsc	///  
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) /* Column 5 for US */
tab year if e(sample)

/* subtract 1 from those where 1 has been added before taking logs */
gen aiddisIBRD_con_0 = aiddisIBRD_con-1
gen aiddisIDA_con_0 = aiddisIDA_con-1

estpost summarize odadisUSA_0 odadisJPN_0 odadisFRA_0 odadisDEU_0 odadisGBR_0 odadisUN_0 odadisWFP_0 odadisUNDP_0 odadisUNICEF_0	///
		odadisUNHCR_0 odadisUNTA_0 odadisAfDB_0 odadisAfDF_0 odadisEU_0 ADBdis_0 aidcomIBRD_con aiddisIBRD_con_0 aidcomIDA_con 	///
		aiddisIDA_con_0 aiddisIMF_con aidnflIMF_con aidnflIMFnoncon_con aidnflIMFcon_con imf_all unsc 	///
		inline_usa voteagainstUSA pariah cwar rgdpl2 war polity2new if e(sample) /* to view on screen */
		
esttab . using "output tables\descriptives.xls", cells("varlabels(`e(labels)') count mean sd min max") noobs tab label replace /* for export */



****** Figure 5.1 Bilateral development aid to UNSC members and non-UNSC members

reg 	odadisUSA_ln unsc	///  
		if hic~=1 & code~="CHN" & code~="RUS" & year>1959, cluster(code) /* Column 5 for US */

bysort unsc: sum odadisUSA_0 if e(sample) 
bysort unsc: sum odadisJPN_0 if e(sample) 
bysort unsc: sum odadisDEU_0 if e(sample) 
bysort unsc: sum odadisGBR_0 if e(sample) 
bysort unsc: sum odadisFRA_0 if e(sample) 


capture log close

